package oop7;

/**
 * @author oldliu
 * @since 1.0
 */
public class Student {
    private String name;
    public final String sex;
    private int age;

    public Student(String name, String sex, int age) {
        this.name = name;
        this.sex = sex;
        this.age = age;
    }

    public Student(String sex) {
        this.sex = sex;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }
//    public void setSex(String s){
//        sex=s;
//    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    //这个比较是有问题！因为obj可能不是Student的实例
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;

        if (!(obj instanceof Student)) {
            return false;
        }
        Student st = (Student) obj;
        return this.getName().equals(st.getName());
    }

    @Override
    public String toString() {
        return "学员{" +
                "姓名='" + name + '\'' +
                ", 性别='" + sex + '\'' +
                ", 年龄=" + age +
                '}';
    }
}
